package top.lemna.account.persistence;

import java.math.BigDecimal;

import jakarta.persistence.AttributeConverter;
import top.lemna.common.Amount;

public class AmountConverter implements AttributeConverter<Amount, BigDecimal> {

  @Override
  public BigDecimal convertToDatabaseColumn(Amount attribute) {
    return attribute.getAmount();
  }

  @Override
  public Amount convertToEntityAttribute(BigDecimal dbData) {
    if (dbData == null)
      return null;
    return new Amount(dbData);
  }

}
